<HTML>
<HEAD>
<TITLE>JavaScript Source Code 3000:  Forms:  Confirmable Order Form</TITLE>
<META HTTP-EQUIV="JavaScript Source Code 3000" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="JavaScript Source Code 3000">
<META NAME="section" CONTENT="Forms">
<META NAME="description" CONTENT="">
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff">

<BR>
<center>
<table width=600 cellpadding=0 cellspacing=10>
<tr>
<td width=468 align=center>

    
    
</td>
<td width=120 align=center>
    
</td>
</tr>
</table>
<BR>
<BR>
<basefont size=3>
<FONT SIZE="+2" FACE="Helvetica,Arial">
<A HREF="../index.htm" /" TARGET="_top"><FONT COLOR="#0000FF"><b>Home</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<A HREF="index.htm" /forms/" ><font color="#FF0000"><b>Forms</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<FONT COLOR="#006666"><b>Confirmable Order Form</b></font></font>
<BR>
<BR>
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE="helvetica,arial,geneva">
<br>
<br>
<!-- Description --><!--content_start-->

Your order has been submitted.  If you entered your email address, it will arrive shortly.  The source code for the order form, the confirm page, and the thanks page are included below.
<hr>
</td></tr>
</table>
<!-- Demonstration -->

<P>
<P>
<a name="source">
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>JavaScript Source Code 3000:  Forms:  Confirmable Order Form</b>
<p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s).  The script is yours!!!
<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size:  0.85 KB" size=24>
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- SIX STEPS TO INSTALL CONFIRMABLE ORDER FORM:

  1.  Create the order form code into the BODY section
  2.  Using the 'value' format to make entries for each item
  3.  Create a new 'confirm-order.html' HTML page
  4.  Copy the next coding into the NEXT of your HTML document
  5.  Paste the onLoad event handler into the BODY tag
  6.  Insert the final code into the BODY of your HTML document  --&gt;

&lt;!-- STEP ONE: Paste this code into the BODY of your HTML document  --&gt;

&lt;!-- Create an HTML order form similar to the one below.
     The confirm-order.html address is your confirm page  --&gt;

&lt;form name=orderform action="confirm-order.html"&gt;
(Just check the items you wish to order.)&lt;p&gt;
&lt;table border=1&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=checkbox name=item1A value="1A-Item_1_is_a_....*15.00$"&gt;&lt;/td&gt;

&lt;!-- STEP TWO: Using this format, add an entry for each sale item

Each item must have a checkbox in the format above.

The value="" is where all the magic happens
Put the Item Number then a dash (-) then the 
description (with underscores for any spaces) 
then a star (*) then the cost, and end with 
a dollar sign ($) like this:  Repeat for each
item for sale.  --&gt;

&lt;td&gt;1A&lt;/td&gt;
&lt;td&gt;Item 1 is a ....&lt;/td&gt;
&lt;td&gt;$15.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=checkbox name=item2A value="2A-Item_2_is_a_....*15.00$"&gt;&lt;/td&gt;
&lt;td&gt;2A&lt;/td&gt;
&lt;td&gt;Item 2 is a ....&lt;/td&gt;
&lt;td&gt;$30.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=checkbox name=item3A value="3A-Item_3_is_a_....*45.00$"&gt;&lt;/td&gt;
&lt;td&gt;3A&lt;/td&gt;
&lt;td&gt;Item 3 is a ....&lt;/td&gt;
&lt;td&gt;$45.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=4 align=center&gt;
&lt;input type=submit value="Order"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;

&lt;!-- STEP THREE: Create a new 'confirm-order.html' document --&gt;

&lt;!-- STEP FOUR: Save this code into the HEAD of your confirm page --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;

&lt;! &gt;
&lt;! &gt;

&lt;!-- Begin
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c &lt; string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;

orderData = "&lt;table border=1 width=400&gt;";
orderData += "&lt;tr&gt;&lt;td&gt;Item&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Cost&lt;/td&gt;&lt;/tr&gt;";
grandTotal = 0;
for (var i = 0; i &lt; dataCount; i++)
{
valNum[i] = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData[i] = string;
else valData[i] = string.substring(0,string.indexOf("&"));
ampd = valData[i].indexOf("&");
pipe = valData[i].indexOf("-");
star = valData[i].indexOf("*");
line = valData[i].indexOf("$");
itemnum = string.substring(0,pipe);
itemdsc = string.substring(pipe+1,star);
itemcst = string.substring(star+1,line);
string = string.substring(ampd+1,string.length);
  
orderData += "&lt;tr&gt;";
orderData += "&lt;input type=hidden name=item" + (i+1) + "num value='" + itemnum + "'&gt;";
orderData += "&lt;input type=hidden name=item" + (i+1) + "dsc value='" + itemdsc + "'&gt;";
orderData += "&lt;input type=hidden name=item" + (i+1) + "cst value='$" + itemcst + "'&gt;";
orderData += "&lt;td&gt;" + itemnum + "&lt;/td&gt;";
orderData += "&lt;td&gt;" + itemdsc + "&lt;/td&gt;";
orderData += "&lt;td&gt;" + itemcst + "&lt;/td&gt;";
orderData += "&lt;/tr&gt;";
grandTotal += parseInt(itemcst);
}
orderData += "&lt;tr&gt;";
orderData += "&lt;td colspan=2 align=center&gt;Total&lt;/td&gt;&lt;td&gt;" + grandTotal + ".00&lt;/td&gt;";
orderData += "&lt;/tr&gt;";
orderData += "&lt;tr&gt;";
orderData += "&lt;td colspan=3 align=center&gt;&lt;input type=submit value='Confirm Order!'&gt; or &lt;a href='javascript:history.go(-1)'&gt;Go Back&lt;/a&gt;&lt;/td&gt;";
orderData += "&lt;/tr&gt;";
orderData += "&lt;input type=hidden name=grandtotal value='$" + grandTotal + ".00'&gt;";
orderData += "&lt;/table&gt;";
document.write(orderData);
}

function openThanks() {
window.open("confirm-order-thanks.html");  // Can be any "thank you" page
}
// End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP FIVE: Add the onLoad event handler into the BODY tag --&gt;

&lt;BODY onUnload="openThanks()"&gt;

&lt;!-- STEP SIX: Paste the last code into the BODY of confirm-order.html

&lt;form method=post action="http://cgi.freedback.com/mail.pl" name="emailform"&gt;

&lt;!-- Don't forget to change this to your email address!  --&gt;

&lt;input type=hidden name=to value="you@your-web-site-address-here.com"&gt;
&lt;input type=hidden name=subject value="** Order Form **"&gt;

&lt;center&gt;
&lt;script language="JavaScript"&gt;
&lt;!-- Begin
decodeString();
// End --&gt;
&lt;/script&gt;
&lt;/center&gt;
&lt;/form&gt;

 

&lt;!-- Script Size:  4.79 KB --&gt;</textarea><br><font FACE="helvetica,arial,geneva"></font></td></tr>

</table>
<br><br>
<!-- </form> -->

    

<p>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getCookieVal (offset) {
var endstr = document.cookie.indexOf(";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = "/"; //(argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

var emailcookie = GetCookie('email_address');
if (emailcookie == null) {
emailcookie = 'your email here';
}

function chk(email, formname)
{
invalid = "";

if (!email)
invalid = "No email address found!  Try reloading the page then use the 'email a script' feature again.";

else {

if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) ) 
invalid += "\n\nInvalid email address.  Your email address is missing an '@' sign and a '.' in the domain name (like '.com').  Please check your address then submit again.";

if (email.indexOf("youremailhere") > -1)
invalid += "\n\nInvalid email address.  Make sure your email address included your username, the '@' sign, and the domain name (like '.com').";

if (email.indexOf("\\") > -1) 
invalid += "\n\nEmail address contains an invalid back-slash (\\) character.  Remove the character and submit again.";

if (email.indexOf("/") > -1) 
invalid += "\n\nEmail address contains an invalid forward-slash (/) character.  Remove the character and submit again.";

if (email.indexOf("'") > -1) 
invalid += "\n\nEmail address contains an invalid apostrophe (') character.  Remove the character and submit again.";

if (email.indexOf("zaz.com.br") > -1) 
invalid += "\n\nPlease do not use an email address that has an autoresponder set up for it.  Thanks.";

if (email.indexOf("!") > -1) 
invalid += "\n\nEmail address contains an invalid exclamation point (!) character.  Remove the character or correct the email address then submit again.";

if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) )
invalid += "\n\nPlease only enter one email address in the box at a time.  Remove the extra addresses and submit again.";

if (email.indexOf("?subject") > -1) 
invalid += "\n\nPlease do not add '?subject=...' to your email address.  Scriptbot will send you the script with a pre-defined subject already.  Please remove the '?subject=...' from your email address and submit again.";
}

if (invalid == "")
   {
   var largeExpDate = new Date();
   largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
   SetCookie('email_address', email, largeExpDate);
   if (formname == "scriptbot")
      {
      page = "http://javascript.internet.com/sent.html?" + email;
      window.open(page, "AdWindow", "width=650,height=200");
      }
   return true;
}
else 
   { 
   alert("Oops, something is wrong...." + invalid);
   return false;
   }
}

function updateNewsletters() {
with (document.forms["newslettersignup"]) {
emailStr = email.value;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; // remove   ( ) < > @ , ; : \ " . [ ]    */
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
return false;;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
      }
   }
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.");
return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
alert("The address must end in a three-letter domain, or two letter country.");
return false;
}
if (len<2) {
var errStr="This address is missing a hostname!";
alert(errStr);
return false;
}
List_Name.value = newsletter.options[newsletter.selectedIndex].value
		+ nltype.options[nltype.selectedIndex].value;

   var largeExpDate = new Date();
   largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
   SetCookie('email_address', emailStr, largeExpDate);

return true;
   }
}
// End -->
</script>

<p>
<center>

<table cellpadding=0 cellspacing=0 border=0 width="620">
<tr>
<td align=left>

